package com.object.oriented.exam.system8.controller;

import com.object.oriented.exam.system1.entity.Problem;
import com.object.oriented.exam.system2.entity.ProblemProperty;
import com.object.oriented.exam.system5.entity.Answer;
import com.object.oriented.exam.system8.entity.Question;
import com.object.oriented.exam.system8.service.PracticeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xdf
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/practice")
public class PracticeController {
    @Resource
    PracticeService practiceService;

    /**
     * 学生提交练习，并获取练习题目的答案和解析等
     * @param answer
     * @return
     */
    @PostMapping("/commit")
    public Question commit(@RequestBody Answer answer){
        return practiceService.commit(answer);
    }

    /**
     * 获取某个知识点的相关题目
     * @param knowledgeId
     * @return
     */
    @GetMapping("/knowledge/{knowledgeId}")
    public List<Problem> practice(@PathVariable Long knowledgeId){
        return practiceService.practice(knowledgeId);
    }
}
